fix: Clarify error message for podman restore without --tcp-established#29026
fix: Clarify error message for podman restore without --tcp-established#29026simek-m wants to merge 1 commit into
Conversation
Newer version of crun use show_criu_log() to report errors from CRIU and output multiple error lines. It lead to confusing behavior in readConmonPipeData() in Podman, because the JSON Unmarshal() failed to parse multiple JSON objects over multiple lines. When podman restore was used without --tcp-established, a confusing error message: cgroupd: recv req error: No such file or directory was output, instead of the former: crun: CRIU restoring failed -52. Parse all errors from the log and try to match "Connected TCP socket in image". If found, return a clear error message. Update tests. Fixes: https://redhat.atlassian.net/browse/RHEL-186005 Signed-off-by: Marek Simek <msimek@redhat.com>
|
Do these work with both runc and crun? |
| if strings.Contains(e.Msg, "Connected TCP socket in image") { | ||
| return fmt.Errorf("checkpoint contains established TCP connections, restore requires --tcp-established or --tcp-close: %w", define.ErrOCIRuntime) | ||
| } | ||
| } |
There was a problem hiding this comment.
that does not seem maintainable, we should not make assumptions about the error text from crun or criu, it changes often enough. Sure the tests depend on it to some extend but we should not make the code depend, i.e. this may not work for another runtime.
It would be better to work with crun and criu to produce better errors to begin with.
Yes, it should work the same with both. [root@lima-default]~# podman container restore server
Error: OCI runtime error: checkpoint contains established TCP connections, restore requires --tcp-established or --tcp-close
[root@lima-default]~# podman info --format '{{.Host.OCIRuntime.Name}}'
runcIt's a CRIU error being matched.
I agree, but that's exactly what caused this bug report. if match := regexp.MustCompile("(?i).*executable file not found in.*|.*no such file or directory.*|.*open executable.*").FindString(runtimeMsg); match != "" {
errStr := match
if includeFullOutput {
errStr = runtimeMsg
}
return fmt.Errorf("%s: %s: %w", name, strings.Trim(errStr, "\n"), define.ErrOCIRuntimeNotFound)
}Unfortunately, there's AFAIK no specific error code returned by crun or CRIU in this case that could be used and that might not be stable either. Alternatively, the whole error output from crun could be shown to the user, or there can be no change at all - it still works as documented. But in my opinion and from the perspective of a user, I'd like to see a helpful error message in this case, even though it's documented in https://docs.podman.io/en/latest/markdown/podman-container-restore.1.html#tcp-established |
which I absolutely hate, the fact we eat up errors and convert them often also creates just more confusing errors as well. It also often has no way of working with multiple different runtimes.
I think parsing the full error log is the right thing to do, if it gives us many lines we should forward all of them |
Thank you. Do you mean getting rid of the whole If so, I think it's quite a big and possibly breaking change in the error messages that would users receive. Anyway, I'd still like finding a way of providing some context to users (in this case guiding them to use the |
I would love to go into that direction. At the minimum I think we should always forward all error messages, i.e. just use the parseOCIErrors() for all messages. We can return a multi line error with errors.Join() for all of them.
Well error messages should provide the proper context what went wrong, they are not a stable API by design.
I don't strictly disagree but overall I find most of these assumption just do not hold long term. If we want better errors I would argue this needs to be pushed back to criu. They know whenever the tcp-established option is set or not, so they could just as well change the message to Also the other problem with this I did not even touch yet is that we really should not hard code cli flags in error message in the backend code. We have a fully support REST API, returning cli arguments to some user who is not using the cli is not useful either. |
Newer versions of crun use
show_criu_log()to report errors from CRIU and output multipleerror lines. It lead to a confusing behavior in
readConmonPipeData()in Podman, becausethe JSON
Unmarshal()failed to parse multiple JSON objects over multiple lines. Whenpodman restorewas used without--tcp-establishedor--tcp-close, a confusing error message:was output, instead of the former:
In this PR, I parse all errors from the log and try to match
"Connected TCP socket in image". If found,
a clear error message is returned:
For other error messages, the existing behavior is retained. Tests were updated with the changed error message.
Steps to reproduce:
Fixes: https://redhat.atlassian.net/browse/RHEL-186005
Checklist
Ensure you have completed the following checklist for your pull request to be reviewed:
commits. (
git commit -s). (If needed, usegit commit -s --amend). The author email must matchthe sign-off email address. See CONTRIBUTING.md
for more information.
Fixes: #00000in commit message (if applicable)make validatepr(format/lint checks)Noneif no user-facing changes)Does this PR introduce a user-facing change?